package com.medusa.aps.business.modules.demand.model.output;

import com.medusa.aps.business.model.enums.SchedulingStatusEnum;
import com.medusa.aps.business.model.enums.SourceEnum;
import com.medusa.aps.business.util.PercentageScheduleUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 分页查询返回实体对象
 *
 * @author shenzhiwei
 */
@Schema(description = "分页查询返回实体对象")
@Data
public class OrderInfoPageListModel {
    /**
     * 主键
     */
    @Schema(description = "主键")
    private Integer id;
    /**
     * 订单号
     */
    @Schema(description = "订单号")
    private String orderNumber;

    /**
     * 物料id
     */
    @Schema(description = "物料id")
    private Long materialId;

    /**
     * 物料编码
     */
    @Schema(description = "物料编码")
    private String itemCode;

    /**
     * 物料名称
     */
    @Schema(description = "物料名称")
    private String itemName;

    /**
     * 物料实际库存
     */
    @Schema(description = "物料实际库存")
    private Integer itemStock;

    /**
     * 客户编码
     */
    @Schema(description = "客户编码")
    private String customerCode;
    /**
     * 客户公司名称
     */
    @Schema(description = "客户公司名称")
    private String customerCompanyName;
    /**
     * 下单日期
     */
    @Schema(description = "下单日期")
    private LocalDate orderDate;
    /**
     * 订单交期
     */
    @Schema(description = "订单交期")
    private LocalDate orderDeliveryDate;
    /**
     * 订单数量
     */
    @Schema(description = "订单数量")
    private Integer orderQuantity;
    /**
     * 计划数量
     */
    @Schema(description = "计划数量")
    private Integer plannedQuantity;

    /**
     * 排产状态
     */
    @Schema(description = "排产状态")
    private SchedulingStatusEnum schedulingStatus;
    /**
     * 计划开始时间
     */
    @Schema(description = "计划开始时间")
    private LocalDateTime plannedStartTime;
    /**
     * 计划结束时间
     */
    @Schema(description = "计划结束时间")
    private LocalDateTime plannedEndTime;
    /**
     * 偏差天数
     */
    @Schema(description = "偏差天数")
    private Integer deviationDays;
    /**
     * 订单进度
     */
    @Schema(description = "订单进度")
    private BigDecimal orderProgress;
    /**
     * 订单优先级
     */
    @Schema(description = "订单优先级")
    private Integer orderPriority;
    /**
     * 是否存在bom
     */
    @Schema(description = "是否存在bom")
    private Boolean hasBom;
    /**
     * 是否存在工艺路线
     */
    @Schema(description = "是否存在工艺路线")
    private Boolean hasProcess;
    /**
     * 创建人
     */
    @Schema(description = "创建人")
    private String creator;
    /**
     * 数据来源
     */
    @Schema(description = "数据来源")
    private SourceEnum dataSource;
    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private LocalDateTime createTime;


    public String getOrderProgress() {
        if (SchedulingStatusEnum.CLOSE == schedulingStatus) {
            return "100.00%";
        }
        return PercentageScheduleUtils.decimalConvertPercentage(orderProgress);
    }

}
